<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <form id="my-form" class="am-form tpl-form-line-form" enctype="multipart/form-data" method="post">
                    <div class="widget-body">
                        {if isset($model['apply_status'])}
                        <div class="tips am-margin-bottom-sm am-u-sm-12">
                        {if $model['apply_status']['value'] ==10}
                            <div class="pre-warning"><p> 提示：资料审核中，有问题会给您电话联系</p></div>
                        {/if}
                        {if $model['apply_status']['value'] ==20}
                            <div class="pre-info"><p> 提示：资料验证中，请在您微信中完成实名验证</p></div>
                        {/if}
                        {if $model['apply_status']['value'] ==30}
                            <div class="pre-success"><p> 提示：申请已通过,您已注册成功</p></div>
                        {/if}
                        {if $model['apply_status']['value'] ==40}
                            <div class="pre-error">
                                <p> 提示：申请被驳回，请按要求修改后提交</p>
                                <p>驳回原因：{$model['reject']}</p>
                            </div>
                        {/if}
                        </div>
                        {/if}
                        <input type="hidden" name="data[business_code]" value="{:isset($model['business_code'])?$model['business_code']:''}">
                        <input type="hidden" name="data[apply_mode]" value="10">
                        <fieldset>
                            <section data-am-widget="accordion" class="am-accordion am-accordion-basic">
                            <dl class="am-accordion-item am-active">
                            <dt class="am-accordion-title" style="padding-bottom:20px;">
                                营业执照信息
                            </dt>
                            <dd class="am-accordion-bd am-collapse am-in">
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">营业执照类型 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[details][subject_type]" value="SUBJECT_TYPE_INDIVIDUAL" data-am-ucheck
                                            {$model['details']['subject_type'] == 'SUBJECT_TYPE_INDIVIDUAL' ? 'checked' : ''} >
                                        个体工商户
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[details][subject_type]" value="SUBJECT_TYPE_ENTERPRISE" data-am-ucheck
                                            {$model['details']['subject_type'] == 'SUBJECT_TYPE_ENTERPRISE' ? 'checked' : ''} >
                                        公司企业
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">营业执照 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-form-file">
                                        {if !isset($model['apply_status']) or (isset($model['apply_status']) and $model['apply_status']['value'] == 40)}
                                         <button type="button" class="am-btn am-btn-secondary am-radius am-btn-sm">
                                            <i class="am-icon-cloud-upload" style="color:#fff"></i>选择图片
                                        </button>
                                        <input type="file" name="license_copy" id="upload" onchange="gome(this)">
                                        {/if}
                                        <div class="uploader-list am-cf">
                                            {if !empty($model['details']['license_copy']['value'])}
                                                <div class="file-item">
                                                    <a href="{$model['details']['license_copy']['url']}" title="点击查看大图" target="_blank">
                                                        <img src="{$model['details']['license_copy']['url']}">
                                                    </a>
                                                    <input type="hidden" name="data[details][license_copy]"
                                                           value="{$model['details']['license_copy']['value']}">
                                                </div>
                                            {/if}
                                        </div>
                                    </div>
                                    <div class="help-block am-margin-top-sm">
                                        <small>大小2M以下</small>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">统一社会信用代码 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][license_number]" value="{$model['details']['license_number']}" required>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">营业执照名称 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][merchant_name]" value="{$model['details']['merchant_name']}" required>
                                    <small>
                                        个体营业执照名称如为空或为“无”，请填写"个体户+经营者姓名"，如“个体户张三”
                                    </small>
                                </div>
                            </div>
                            </dd>
                            </dl>
                            <dl class="am-accordion-item am-active">
                            <dt class="am-accordion-title" style="padding-bottom:20px;">
                                经营者/法人信息
                            </dt>
                            <dd class="am-accordion-bd am-collapse am-in">
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">身份证（正面） </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-form-file">
                                        {if !isset($model['apply_status']) or (isset($model['apply_status']) and $model['apply_status']['value'] == 40)}
                                         <button type="button" class="am-btn am-btn-secondary am-radius am-btn-sm">
                                            <i class="am-icon-cloud-upload" style="color:#fff"></i>选择图片
                                        </button>
                                        <input type="file" name="id_card_copy" id="upload" onchange="gome(this)">
                                        {/if}
                                        <div class="uploader-list am-cf">
                                            {if !empty($model['details']['id_card_copy']['value'])}
                                                <div class="file-item">
                                                    <a href="{$model['details']['id_card_copy']['url']}" title="点击查看大图" target="_blank">
                                                        <img src="{$model['details']['id_card_copy']['url']}">
                                                    </a>
                                                    <input type="hidden" name="data[details][id_card_copy]"
                                                           value="{$model['details']['id_card_copy']['value']}">
                                                </div>
                                            {/if}
                                        </div>
                                    </div>
                                    <div class="help-block am-margin-top-sm">
                                        <small>身份证所有人必须跟营业执照法人（所有人）姓名一致。大小2M以下</small>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">身份证（反面） </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-form-file">
                                        {if !isset($model['apply_status']) or (isset($model['apply_status']) and $model['apply_status']['value'] == 40)}
                                         <button type="button" class="am-btn am-btn-secondary am-radius am-btn-sm">
                                            <i class="am-icon-cloud-upload" style="color:#fff"></i>选择图片
                                        </button>
                                        <input type="file" name="id_card_national" id="upload" onchange="gome(this)">
                                        {/if}
                                        <div class="uploader-list am-cf">
                                            {if !empty($model['details']['id_card_national']['value'])}
                                                <div class="file-item">
                                                    <a href="{$model['details']['id_card_national']['url']}" title="点击查看大图" target="_blank">
                                                        <img src="{$model['details']['id_card_national']['url']}">
                                                    </a>
                                                    <input type="hidden" name="data[details][id_card_national]"
                                                           value="{$model['details']['id_card_national']['value']}">
                                                </div>
                                            {/if}
                                        </div>
                                    </div>
                                    <div class="help-block am-margin-top-sm">
                                        <small>身份证所有人必须跟营业执照法人（所有人）姓名一致。大小2M以下</small>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 证件姓名 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][id_card_name]" value="{$model['details']['id_card_name']}" required>
                                    <small>身份证上面的姓名</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 证件号码 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][id_card_number]" value="{$model['details']['id_card_number']}" required>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 居住地址 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][id_card_address]" value="{$model['details']['id_card_address']}" required>
                                    <small>身份证上面的居住地址</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 身份证有效期开始时间 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][card_period_begin]" value="{$model['details']['card_period_begin']}" required>
                                    <small>示例值：2026-06-06</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 身份证有效期结束时间 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][card_period_end]" value="{$model['details']['card_period_end']}" required>
                                    <small>示例值：2036-06-06</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 联系电话 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][mobile_phone]" value="{$model['details']['mobile_phone']}" required>
                                    <small>
                                        请填写手机号，请确保电话畅通以便平台回拨确认
                                    </small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 微信号 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" 
                                    name="data[details][legal_persona_wechat]" value="{$model['details']['legal_persona_wechat']}" required>
                                    <small>不是绑定的手机号！请打开微信->我的->点击头像->查看微信号<br>
                                    微信必须实名认证，并与上面身份证姓名一致。</small>
                                </div>
                            </div>
                            </dd>
                            </dl>
                            {if !isset($model['apply_status']) or (isset($model['apply_status']) and $model['apply_status']['value'] == 40)}
                            {if $ability['applet_apply'] == 1}
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">平台审核 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[apply_status]" value="10" data-am-ucheck>
                                        提交平台辅助申请
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="data[apply_status]" value="20" data-am-ucheck checked>
                                        直接提交申请
                                    </label>
                                </div>
                            </div>
                            {else/}
                                <input type="hidden" name="data[apply_status]" value="10">
                            {/if}
                            <div class="am-modal am-modal-loading am-modal-no-btn" tabindex="-1" id="my-modal-loading">
                            </div>
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
                                    <button type="submit" class="j-submit am-btn am-btn-secondary">提交</button>
                                </div>
                            </div>
                            {/if}
                        </section>
                        </fieldset>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    //建立一可存取到file的url
     function getObjectURL(file) {
         var url = null;
         if (window.createObjectURL != undefined) { // basic
             url = window.createObjectURL(file);
         } else if (window.URL != undefined) { // mozilla(firefox)
             url = window.URL.createObjectURL(file);
         } else if (window.webkitURL != undefined) { // webkit or chrome
             url = window.webkitURL.createObjectURL(file);
         }
         return url;
     }
    
    function gome(obj) {
        var objUrl = getObjectURL(obj.files[0]); //获取图片的路径，该路径不是图片在本地的路径
        if (objUrl) {
            //将图片路径存入src中，显示出图片
            $(obj).parent().find('.uploader-list').html("<div class='file-item'><img src='"+objUrl+"'></div>");
        }
    }
    $(function () {
        
         // 上传图片 获取图片的宽高 文件大小
         var _URL = window.URL || window.webkitURL;
         //营业执照
         $("#upload").change(function(e) {
             var file, img;
             if ((file = this.files[0])) {
                 img = new Image();
                 img.onload = function() {
                    if(file.size > 2097152){
                        alert("图片大小不能超过2M");
                    }
                     //alert('图片宽：' + this.width + " 图片高：" + this.height + " 图片大小：" + file.size);
                 };
                 img.src = _URL.createObjectURL(file);
             }
         });
        $('#my-form').formPost();

    });
</script>